<!DOCTYPE html>
<html lang="Zn-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上传文章</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <nav>
        <div class="menu-icon2">小盒子社区</div>
        <div class="toolbox">
            <button class="search-icon" onclick="navigateToSearch()"><i>&#128269;</i></button>
            <div class="dropdown" onclick="toggleDropdown()">
                ☰
                <div class="dropdown-content">
                    <a href="">首页</a>
                    <a href="search">作品搜索</a>
                    <a href="user/{{ session['username'] }}">个人中心</a>
                    <a href="tougaoscratch">投稿作品</a>
                    <a href="upbook">投稿博客</a>
                    <a href="{{ url_for('logout') }}">登出</a>
                    <a href="users">用户更改</a>
                </div>
            </div>
            <button class="theme-toggle" onclick="toggleTheme()">&#9788;</button>
        </div>
    </nav>

    <div class="container">
        <h1>上传文章</h1>
        <form method="POST" enctype="multipart/form-data">
            <div class="form-group">
                <label class="form-label" for="name">文章标题:</label>
                <input type="text" class="form-control" id="name" name="name" required>
            </div>

            <div class="form-group">
                <label class="form-label" for="content">内容:</label>
                <textarea class="form-control textarea-control" id="content" name="content" required style="height: 600px;"></textarea>
            </div>

            <div class="form-group">
                <button type="submit" class="submit-btn">上传</button>
            </div>
        </form>
    </div>

    <footer>
        <p>2025 小盒子社区</p>
        <p>代理官方：<a href="https://space.bilibili.com/3493133419546943?spm_id_from=333.1296.0.0">bilibili</a></p>
        网站相关 <a href = "/required">使用小盒子必读</a> | <a href = "/advise">提交创意</a> | <a href="/download">下载相关软件</a> | <a href="https://baike.baidu.com/item/%E4%BA%92%E8%81%94%E7%BD%91%E7%AB%99%E7%A6%81%E6%AD%A2%E4%BC%A0%E6%92%AD%E6%B7%AB%E7%A7%BD%E3%80%81%E8%89%B2%E6%83%85%E7%AD%89%E4%B8%8D%E8%89%AF%E4%BF%A1%E6%81%AF%E8%87%AA%E5%BE%8B%E8%A7%84%E8%8C%83">互联网自律公约</a><br>
        常用网站 <a href = "https://donvie.top">donvie</a> | <a href = "https://www.rainyun.com/NzMxMjkw_">雨云</a><br>
        特别鸣谢 <a href = "https://space.bilibili.com/3493133419546943">吾家小狐(提供主要代码)</a> | <a href="https://space.bilibili.com/1120402022">Donvies(前端支持)</a> | <a href="https://space.bilibili.com/1128177448">yangyi(服务器支持)</a><br>
        解决方案 <a href = "/ad">广告推广</a>
        <p>QQ交流群：1037989684</p>
    </footer>

    <script>
        function toggleDropdown() {
            const dropdown = document.querySelector('.dropdown');
            dropdown.classList.toggle('open');
        }

        function toggleTheme() {
            const html = document.documentElement;
            if (html.getAttribute('data-theme') === 'light') {
                html.removeAttribute('data-theme');
                localStorage.setItem('theme', 'dark');
            } else {
                html.setAttribute('data-theme', 'light');
                localStorage.setItem('theme', 'light');
            }
        }

        document.addEventListener('click', function (event) {
            const dropdown = document.querySelector('.dropdown');
            if (!dropdown.contains(event.target)) {
                dropdown.classList.remove('open');
            }
        });

        // 页面加载时根据本地存储设置主题
        const savedTheme = localStorage.getItem('theme');
        if (savedTheme === 'light') {
            document.documentElement.setAttribute('data-theme', 'light');
        }

        // 跳转到搜索页面
        function navigateToSearch() {
            window.location.href = "search";
        }
    </script>
</body>
</html>